Ext.Loader.load(['js/module/audit/subpanel/reportRetrive.js']);
//模块主窗口
workFlowDetail = Ext.extend(Ext.Panel,{
	 closable: true,
   	 autoScroll:true,
   	 width:'100%',
   	 initComponent : function() {
   			this.tbar =  this.buildBbar() ;
   			var gd = new workFlowDetail.Grid() ;
   			this.items = [gd] ;
			
   		workFlowDetail.superclass.initComponent.call(this);
   	 },
   	 buildBbar: function() {
		return ['->',{
                      text:'操作说明'          
                      ,iconCls:'ico-dot-question'
                      ,handler:function(btn){}
		}]
   	 },
   	 exportData:function(btn) {
   		
   		
   	} 
});



//高额用户信息列表
workFlowDetail.Grid = Ext.extend(Ext.grid.GridPanel,{
	title : '流程运行状态',
	header: false,
	loadMask:{msg:'加载中...'},
	enableDragDrop: false,
	columnLines:true,
	height: 600,
	viewConfig :{
        forceFit: true
    },
	initComponent : function() {
       	var thisGrid = this;
       	this.recordStart = 1 ;
    	var checkBoxCm = new Ext.grid.CheckboxSelectionModel({
				dataIndex: "uid",
                sortable: false,
                singleSelect:false,
                width:20
		});
		var recordNum = new　Ext.grid.RowNumberer({
		　　header　:　"序号",
		　　width　:　35,
		　　renderer:function(value,metadata,record,rowIndex){
		　　　return　　thisGrid.recordStart　+　rowIndex;
		　　}
		});
	
		this.columns　=　[checkBoxCm,recordNum,　
		    {
				header:'稽核点名称',
				sortable:true,
				dataIndex:"taskName",
				width:150
			},{
				header:'主流程名称',
				sortable:true,
				dataIndex:"aliasName",
				width:120
			},{
				header:'问题单描述',
				sortable:true,
				dataIndex:"issueInfo",
				width:150,
				renderer: function(value, metaData, record, rowIndex, colIndex, store) {
		   			metaData.attr = ' ext:qtip="' + value + '"';
		   			return value;
		   		}
			},{
				header:'严重级别',
				sortable:true,
				dataIndex:"warnLevel",
				width:60
			},{
				header:'流程运行状态',
				sortable:true,
				dataIndex:"procStateName",
				width:70,
				renderer: function(value, metaData, record, rowIndex, colIndex, store){
					var procState = record.data["procState"];
					switch(procState){
						case "1":
							return "<img src='images/dot_green.gif'/>"+value;
							break;
						case "2":
						case "0":
							return "<img src='images/dot_yellow.gif'/>"+value;
							break;
						case "3":
							return "<img src='images/dot_gray.gif'/>"+value;
							break;
						case "4":
							return "<img src='images/dot_blue.gif'/>"+value;
							break;
					}
				}
			},{
				header:'创建时间',
				sortable:true,
				dataIndex:"startTime"
			},{
				header:'结束时间',
				sortable:true,
				dataIndex:"endTime"
			},{
				header:'操作',
				xtype: 'actioncolumn',
            	width: 50,
            	align :"center",
           		items: [
                {
                    icon   : 'images/home/search-add.png',                // Use a URL in the icon config
                    tooltip: '查看稽核任务处理详情',
                    handler: function(grid, rowIndex, colIndex) {
							 var taskId = grid.getStore().getAt(rowIndex) .data['taskId'];
	                		var processInstId = grid.getStore().getAt(rowIndex) .data['procInstId'];
	                		new workFlowDetail.process({taskId:taskId,processInstId:processInstId}).show();
                    }
                },{
                    icon   : 'images/add.gif',                // Use a URL in the icon config
                    tooltip: '查看稽核报告',
                    handler: function(grid, rowIndex, colIndex) {
							  var rec = grid.getStore().getAt(rowIndex);
							  var params={};
							  params.taskId=rec.get('taskId');
							  params.mainProcessId=rec.get('mainProcessId');
							  params.taskSeqNo=rec.get('taskSeqNo');
							  Audit.Report.reportRetrive.show(params);
                    }
                }]
			}] ;
		var dataStore = new Ext.data.JsonStore({
			url : 'work_getWorkFlowDetail.action',
			root: 'root',
	        totalProperty: 'totalProperty',
	        idProperty: 'id',
	        fields: [
				'id','taskName','aliasName','issueInfo','warnLevel','procState'
				,'procStateName','startTime','endTime','taskId','procInstId','procDefId'
				,'mainProcessId','taskSeqNo']
		});
	
	    dataStore.baseParams ={'highFeeUser':null};
		this.store = dataStore;
		this.sm = checkBoxCm;
		this.mk=new Ext.LoadMask(Ext.getBody(),{
							msg:'正在努力为您加载数据，请稍候...'
				});
		this.bbar = new Ext.PagingToolbar({
			pageSize : 100,
			store : dataStore,
			displayInfo : true,
			displayMsg : '第 {0} - {1} 条  共 {2} 条',
			emptyMsg : "没有记录",
			listeners:{
				beforechange:function(pt,obj) {
					thisGrid.recordStart = obj.start+1 ;
				}
			}
		});
	workFlowDetail.Grid.superclass.initComponent.call(this);
	},
	listeners : {
   		'afterrender':function(com) {
   			com.getStore().load({
					params:{
					start:0,
					limit:100
					}
			});
   		}
   	}
});

workFlowDetail.process = Ext.extend(Ext.Window,{
	title:'处理详情',
	width:1100,
	height:550,
	layout:'border',
	modal:true,
	closeAction:'close',
	initComponent: function(){
		this.items = [new workFlowDetail.process.treeGrid({taskId:this.taskId,processInstId:this.processInstId})];
//		this.html = "<embed allowscriptaccess=\"never\" allownetworking=\"internal\" invokeurls=\"false\" " +
//					"src=\"HelloWorld.swf\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" " +
//					"type=\"application/x-shockwave-flash\" quality=\"high\" autostart=\"0\" " +
//					"wmode=\"transparent\" width=\"100%\" height=\"300\" align=\"middle\">";
		workFlowDetail.process.superclass.initComponent.call(this);
	}
});

workFlowDetail.process.treeGrid = Ext.extend(Ext.ux.tree.TreeGrid,{
	region:'center',
	autoScroll:true,
	enableSort:false,
	lines:true,
	columns:[{
            header: '维护组名称 | 稽核任务名称',
            dataIndex: 'groupName',
            width: 400,
            sortable: false
        },{
            header: '组长',
            width: 100,
            dataIndex: 'groupLeader'
        },{
            header: '组员',
            width: 100,
            dataIndex: 'groupMember'
        },{
            header: '处理人员',
            width: 100,
            dataIndex: 'staffName'
        },{
            header: '处理状态',
            width: 50,
            dataIndex: 'status',
            renderer: function(value, metaData, record, rowIndex, colIndex, store) {
	   			metaData.attr = ' ext:qtip="' + value + '"';
	   			return "<img src='images/infocard.png'/>"+value ;
	   		}
        },
        {
            header: '开始时间',
            width: 150,
            dataIndex: 'startTime'
        },{
            header: '结束时间',
            width: 150,
            dataIndex: 'endTime'
        }],
	listeners:{
		'beforecollapsenode' : function(){
			return false;
		}
	},
	initComponent: function(){
		this.dataUrl = 'work_getProcessDetail.action?taskId='+this.taskId+'&processId='+this.processInstId;
		workFlowDetail.process.treeGrid.superclass.initComponent.call(this);
	}
});


